document.write("<script src='/js/server.js'></script>");



function show(msg, fun, chname) {
    top.show(msg, fun, chname);
}
function msg(msg, fun, chname) {
    top.msg(msg, fun, chname);
}
function showclose(res) {
    top.showclose(res);
}
function showerror(msg, err) {
     top.showerror(msg, err);
}
function showconfirm(msg, fun, chname) {
    top.showconfirm(msg, fun, chname);
}

function showwin(winID, winSrc, winchname, winWidth, winHeight) {
    top.showwin(winID, winSrc, winchname, winWidth, winHeight, window);
}

function closewin() { //关闭窗口
    top.closewin(top.layer.getFrameIndex(window.name))
}

function getparentwin(winID) { //获取父窗口
    return top.getparentwin(winID);
}

function getchildframe(winname) { //获取iframe

    return top.getchildframe();
}

function getchildobject(winname, childID) { //获取iframe中子元素对象
    return top.getchildobject(winname, childID);
}

function loading(isshow) {
    top.loading(isshow);
}


function getSrm(word, HZSRM1) {
    if(HZSRM1==null)
        HZSRM1="HZSRM1";
    var py=Pinyin($(word).val());
    if(py.length>6)
        py=py.substr(0,6);
    $("#" + HZSRM1).val(py);

}


//判断某个值在数组中的位置
Array.prototype.indexOf = function (e) {
    for (i = 0; i < this.length; i++) {
        if (this[i] == e)
            return i;
    }
    return -1;
}
//字符串超出省略
String.prototype.cutstr = function (len) {
    var restr = this;
    var wlength = this.replace(/[^\x00-\xff]/g, "**").length;
    if (wlength > len) {
        for (var k = len / 2; k < this.length; k++) {
            if (this.substr(0, k).replace(/[^\x00-\xff]/g, "**").length >= len) {
                restr = this.substr(0, k) + "...";
                break;
            }
        }
    }
    return restr;
}
//替换全部
String.prototype.replaceAll = function (s1, s2) {
    return this.replace(new RegExp(s1, "gm"), s2)
}
//字符串去空格
String.prototype.trim = function () {
    return this.replace(/(^\s*)|(\s*$)/g, "");
}
String.prototype.trimAll = function () {
    return this.replace(/\s+/g, "");
}
String.prototype.ltrim = function () {
    return this.replace(/(^\s*)/g, "");
}
String.prototype.rtrim = function () {
    return this.replace(/(\s*$)/g, "");
}
//判断是否以某个字符串开头
String.prototype.startWith = function (s) {
    return this.indexOf(s) == 0
}
//判断是否以某个字符串结束
String.prototype.endWith = function (s) {
    var d = this.length - s.length;
    return (d >= 0 && this.lastIndexOf(s) == d)
}
function getDateTime(){
    var date = new Date();
    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    var day = date.getDate();
    var hours = date.getHours();
    var minutes = date.getMinutes();
    var seconds = date.getSeconds();
    var currentDate = year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
    return currentDate;
}
toDate= function(DateStr) {
    if(DateStr!=null&&DateStr!="") {
    var dt = new Date(DateStr);
    var year = dt.getFullYear();
    var month = dt.getMonth() + 1;
    if(month.toString().length==1)
        month="0"+month;
    var date = dt.getDate();
    if(date.toString().length==1)
        date="0"+date;
    return year + "-" + month + "-" + date;
    }else {
        return "";
    }
}
toDateTime= function(DateStr)  {
    if(DateStr!=null&&DateStr!="") {
    var dt = new Date(DateStr);
    var year = dt.getFullYear();
    var month = dt.getMonth() + 1;
    if(month.toString().length==1)
        month="0"+month;
    var date = dt.getDate();
    if(date.toString().length==1)
        date="0"+date;
    var hour = dt.getHours();
    if(hour.toString().length==1)
        hour="0"+hour;
    var minute = dt.getMinutes();
    if(minute.toString().length==1)
        minute="0"+minute;
    var second = dt.getSeconds();
    if(second.toString().length==1)
        second="0"+second;
    return year + "-" + month + "-" + date + " " + hour + ":" + minute + ":" + second;
    }else {
        return "";
    }
}
function getParam(name) {
    var result = location.search.match(new RegExp("[\?\&]" + name + "=([^\&]+)", "i"));
    if (result == null || result.length < 1) {
        return "";
    }
    return result[1];
}

function treeReplace(data,id,title) {
    var tempData=JSON.stringify(data);
    tempData=tempData.replaceAll(title,"title").replaceAll(id,"id");
    return JSON.parse(tempData);
}
function xmSelectReplace(data,value,name) {
    var tempData=JSON.stringify(data);
    tempData=tempData.replaceAll(name,"name").replaceAll(value,"value");
    return JSON.parse(tempData);
}






